<?php

include '_init_.php';
	$orderManager = Order_Manager::getOrderManager($_REQUEST['id']);
if($orderManager == null)
	exit("Not exist");
if($orderManager->getStatus() != Order_Manager::$STATUS_SAVED)
	exit("Not allowed");
$orderManager->init();
$orderInfo = $orderManager->getInfo();
$dtFrame = new DataTable(constant('DB_TABLE_PHOTO_FRAME'));
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
if($act == 'save')
{
	$zoom_frame_list = $orderInfo['zoom_frame_list'];
	$zooom_frame_data = &$zoom_frame_list[$_REQUEST['frame_index']];
	$zooom_frame_data['size_id'] = $_REQUEST['size_id'];
	$zooom_frame_data['frame_id'] = $_REQUEST['frame_id'];
	if(intval($_REQUEST['frame_id']) > 0)
	{
		$frameData = $dtFrame->get($_REQUEST['frame_id']);
		$zooom_frame_data['frame_name'] = $frameData['name'];
	}else{
		$zooom_frame_data['frame_name'] = '';
	}
	$zooom_frame_data['is_gift'] = isset($_REQUEST['is_gift'])?'Y':'N';
	$updateOrderData = array('zoom_frame_list'=>$zoom_frame_list);

	$orderManager->setInfo($updateOrderData);
	$orderManager->persistOrderInfo();
	AppMain::refreshParentFrame();
}


$framList = $dtFrame->get_list('','name');
$zoom_frame_list = $orderInfo['zoom_frame_list'];
$zooom_frame_data = $zoom_frame_list[$_REQUEST['frame_index']];
$dtSize = new DataTable(constant('DB_TABLE_PHOTO_SIZE'));
$sizeData = $dtSize->get($_REQUEST['size_id']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form action="cosig.php">
<input type="hidden" name="act" value="save"/>
<input type="hidden" name="id" value="<?php echo $orderManager->getId();?>"/>
<input type="hidden" name="size_id" value="<?php echo Util::html_safe($_REQUEST['size_id']);?>"/>
<input type="hidden" name="frame_index" value="<?php echo Util::html_safe($_REQUEST['frame_index']);?>"/>

<div id="article-admin" class="clearfix">
  <ul>
  	<li class="article-1c" style="color: #990000;"><input type="checkbox" class="article-adminb-chbox" name="is_gift" <?php if($zooom_frame_data['is_gift'] == 'Y'):?> checked="checked" <?php endif;?>>贈品 </li>
   <li class="article-1c">
     相片尺寸<img src="images/line3.gif" width="21" height="12" /><?php echo $sizeData['name'];?></li>
    <li class="article-1c">
     框號
    <select name="frame_id" class="maine-keyinm2" >
         <option value="">無</option>
         <?php foreach($framList as $tmpData):?>
         <option <?php if($tmpData['id'] == $zooom_frame_data['frame_id']):?>selected="selected"<?php endif;?> value="<?php echo $tmpData['id'];?>"><?php echo $tmpData['name'];?></option>
         <?php endforeach;?>
       </select></li>
     <li class="article-1b">
       <input name="" type="button" class="article-1a_btn" value="儲存" onclick="document.forms[0].submit();return false;"/></li>
  </ul>

</div>
</form>
</body>
</html>
